package com.xie.smfs.item;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.world.World;
import com.xie.smfs.common.events.PlayerEvents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SilentGhostEyeItem extends BaseGhostEyeItem {
    private static final Logger LOGGER = LoggerFactory.getLogger(SilentGhostEyeItem.class);

    public SilentGhostEyeItem(Settings settings) {
        super(settings.maxCount(1), 500, 15, 10); // 确保物品不可堆叠
    }

    @Override
    public Text getName(ItemStack stack) {
        return Text.translatable("item.smfs.silent_ghost_eye");
    }

    @Override
    protected Text getBindSuccessMessage(int slot) {
        return Text.translatable("item.smfs.silent_ghost_eye.bind_success")
                .append(Text.literal(" (槽位 " + (slot + 1) + ")"));
    }

    @Override
    protected void sendSlotsFullMessage(PlayerEntity player) {
        // 检查所有槽位状态并记录日志 - 使用相同的判断标准
        NbtCompound ghostSlots = PlayerEvents.getGhostSlots((ServerPlayerEntity) player);
        for (int i = 0; i < 6; i++) {
            String slotKey = "Slot" + i;
            NbtCompound slotData = ghostSlots.getCompound(slotKey);
            boolean isOccupied = slotData.getBoolean("occupied");
            LOGGER.info("Ghost slot {} status: {}, data: {}", i, isOccupied ? "occupied" : "empty", slotData);
        }
        player.sendMessage(Text.literal("槽位已满，无法绑定更多"), true);
    }
}